//index.js
//获取应用实例
const app = getApp()

Page({
  
  data: {
    list: [
      {
        src: "../../images/白玫瑰-对你的思念.jpg",
        info: "白玫瑰",
        msg: "对你的思念 "
      },
      {
        src: "../../images/e.jpg",
        info: "丁香",
        msg: "渴望 "
      },
      {
        src: "../../images/百合花.jpg",
        info: "百合花",
        msg: " "
      },
      {
        src: "../../images/百子莲（产于非洲的爱情花）.jpg",
        info: "产于非洲的爱情花",
        msg: " "
      },
      {
        src: "../../images/美玉.jpg",
        info: "美玉",
        msg: "初恋 "
      },
      {
        src: "../../images/雪莲花.jpg",
        info: "雪莲花",
        msg: "盼望 "
      },
      
      {
        src: "../../images/鸡蛋花.jpg",
        info: "鸡蛋花",
        msg: "可爱的你 "
      },
      {
        src: "../../images/红玫瑰.jpg",
        info: "红玫瑰",
        msg: "热情执着的爱。 "
      },
      {
        src: "../../images/毛地黄.jpg",
        info: "毛地黄",
        msg: "思念、青春、梦境、真心喜欢 "
      },
     
      {
        src: "../../images/夜来香.jpg",
        info: "夜来香",
        msg: "静悄悄的暗恋 "
      },

      {
        src: "../../images/月光守护者.jpg",
        info: "月光守护者",
        msg: "保护 "
      },
    
    {
      src: "../../images/马蹄兰.jpg",
      info: "马蹄兰", 
      msg: "  "
    },
    {
      src: "../../images/琉璃苣.jpg",
      info: "琉璃苣", 
      msg: "热情、魅力、真情 "
    },
    {
      src: "../../images/藜芦.jpg",
      info: "藜芦",
      msg: "高洁 理想之恋 "
    },
    {
      src: "../../images/当归花.jpg",
      info: "当归花",
      msg: "怜取眼前人 幸福 坚韧 "
    },
    {
      src: "../../images/a.jpg",
      info: "a",
      msg: " "
    },
    {
      src: "../../images/b.jpg",
      info: "b",
      msg: " "
    },
    {
      src: "../../images/c.jpg",
      info: "c",
      msg: " "
    },
    {
      src: "../../images/d.jpg",
      info: "d",
      msg: " "
    },
    {
      src: "../../images/i.jpg",
      info: "i",
      msg: " "
    },
    {
      src: "../../images/矮牵牛.jpg",
      info: "矮牵牛",
      msg: ""
    },
    {
      src: "../../images/大丽花.jpg",
      info: "大丽花",
      msg: ""
    },
    {
      src: "../../images/和平棕榈花.jpg",
      info: "和平棕榈",
      msg: ""
    },
    {
      src: "../../images/红景天.jpg",
      info: "红景天",
      msg: ""
    },
    {
      src: "../../images/花黄金-海芋.jpg",
      info: "花黄金",
      msg: ""
    },
    {
      src: "../../images/西康玉兰.jpg",
      info: "花黄金",
      msg: ""
    },
    {
      src: "../../images/园艺花卉.jpg",
      info: "园艺",
      msg: ""
    },
    {
      src: "../../images/紫雏菊.jpg",
      info: "紫雏菊",
      msg: ""
    },
    {
      src: "../../images/紫闪耀.jpg",
      info: "紫闪耀",
      msg: ""
    },
    ],
    
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },

  //事件处理函数
  searchClick: function () {
    wx.navigateTo({
      url: '../cart/cart'
    })
  },

  onLoad: function () {
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      })
    } else if (this.data.canIUse) {
      // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          })
        }
      })
    }
  },
  getUserInfo: function (e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  }
})
